﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management;
using System.Text;
using WMI.NET.Abstracts;

namespace WMI.NET.ComputerSystemHardware.MotherboardControllerPort
{
    /// <summary>
    /// The Win32_PortResource WMI class represents an I/O port on a computer system running Windows.
    /// </summary>
    public class Win32_PortResource : Win32_SystemMemoryResource
    {

        private Nullable<Boolean> _Alias;

        /// <summary>
        /// If TRUE, this instance represents one of the ranges with an alias. If FALSE, the instance represents a base port address. A base port address is a predetermined port address dedicated to a specific service or device. A port alias address is one that a device responds to as if it were the actual address of an I/O port.
        /// </summary>
        public Nullable<Boolean> Alias { get { return _Alias; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public Win32_PortResource(ManagementBaseObject mbo)
            :base(mbo)
        {
            _Alias = mbo.GetBoolValue("Alias");
        }

    }

    /// <summary>
    /// 
    /// </summary>
    public class GetWin32_PortResources : Win32Collection<Win32_PortResource>
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ReadOnlyCollection<Win32_PortResource> GetCollection()
        {
            List<Win32_PortResource> tempCollection = new List<Win32_PortResource>();

            foreach (var s in searcher.Get())
            {
                Win32_PortResource tempListItem = new Win32_PortResource(s);
                tempCollection.Add(tempListItem);
            }

            return tempCollection.AsReadOnly();
        }

        /// <summary>
        /// 
        /// </summary>
        public GetWin32_PortResources() : base("SELECT * FROM Win32_PortResource") { }

    }


}
